<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/24/024
 * Time: 17:00
 */

namespace app\api\controller;

use think\Db;
use think\Request;

class Course extends Rest{

    public function index(){

    }

    public function save(){

    }

    public function read(){

    }

    public function add(){

    }

    public function getCourse(){
//        if (1 != self::check_power(1)) {
//            return $this->data;
//        }
        $request = Request::instance();
        $data = $request->param();
        $class = $data['type'];
        $result = Db::name('course')->where(['type'=>$class])->order('history_date asc')->select();

        foreach($result as $key=> $value){
            $strtimes = explode(" ",$value['history_date']);
            $timearray = explode("-",$strtimes[0]);
            $year = $timearray[0];
            $month = $timearray[1];
            $day = $timearray[2];
            $result[$key]['year'] = $year;
            $result[$key]['month'] = $month;
            $result[$key]['day'] = $day;
        }
        $this->data["code"] = 0;
        $this->data["data"] = $result;

        return $this->data;
    }

}